package com.cirkana.viewer.security;

import java.io.DataInputStream;
import java.io.DataOutputStream;

import com.cirkana.serial.SerializablePassData;
import com.cirkana.serial.SerializationException;
import com.cirkana.viewer.security.model.Profile;

public class SignInPassData extends SerializablePassData {

	private Profile profile;

	public boolean hasProfile() {
		return this.profile != null;
	}

	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	public SignInPassData() {
	}
	
	public SignInPassData(Profile profile) {
		this.profile = profile;
	}

	@Override
	public void serialize(DataOutputStream out) throws SerializationException {
		serializeSerializable(this.profile, out);
	}

	@Override
	public void deserialize(DataInputStream in) throws SerializationException {
		this.profile = (Profile) deserializeSerializable(Profile.class, in);
	}

	@Override
	public String toString() {
		StringBuilder s = new StringBuilder("{");

		s.append("profile=");
		if (this.profile == null)
			s.append("(null)");
		else
			s.append(this.profile.toString());

		s.append("}");
		return s.toString();
	}
}
